package com.jiayang.hhotel.base;

import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import cn.droidlover.xdroidmvp.mvp.XActivity;

/**
 * Created by zj on 2017/4/10 0010.
 */

public abstract class BaseFragment extends Fragment {
    protected XActivity mActivity;
    protected abstract void initView(View view, Bundle savedInstanceState);
    //获取布局文件ID
    protected abstract int getLayoutId();
    //获取宿主Activity
    protected XActivity getHoldingActivity(){
        return mActivity;
    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        this.mActivity=(XActivity)context;
    }
//    //添加Fragment
//    protected void addFragment(BaseFragment fragment){
//            if (null!=fragment){
//                getHoldingActivity().addFragment(fragment);
//            }
//    }
//    //移除fragment
//    protected void removeFragment() {
//        getHoldingActivity().removeFragment();
//    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(getLayoutId(), container, false);
        initView(view, savedInstanceState);
        return view;
    }
}
